package com.itheima.tanhua.web;


import com.itheima.tanhua.service.RecommendService;
import com.itheima.tanhua.vo.NearUserVo;
import com.itheima.tanhua.vo.PageResult;
import com.itheima.tanhua.vo.TodayBestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class TanhuaController {

    @Autowired
    private RecommendService recommend1Service;


    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){
         TodayBestVo todayBestVo=recommend1Service.todayBest();
        return ResponseEntity.ok(todayBestVo);
    }

    @GetMapping("/recommendation")
    public ResponseEntity recommendation(Integer page,Integer pagesize){
        PageResult pageResult=recommend1Service.recommendation(page,pagesize);
        return ResponseEntity.ok(pageResult);
    }

    @GetMapping("/{id}/personalInfo")
    public ResponseEntity personalInfo(@PathVariable("id") Long id){
       TodayBestVo personalInfo= recommend1Service.personalInfo(id);
        return ResponseEntity.ok(personalInfo);
    }


    @GetMapping("/strangerQuestions")
    public ResponseEntity requestQuestions(Long userId){
        String data= recommend1Service.strangerQuestions(userId);
        return ResponseEntity.ok(data);
    }

    @PostMapping("/strangerQuestions")
    public ResponseEntity responseQuestions(@RequestBody Map<String,String> pararm){
        recommend1Service.responseQuestions(pararm);
        return ResponseEntity.ok(null);
    }

    @GetMapping("/cards")
    public ResponseEntity cards(){
      List<TodayBestVo> data=recommend1Service.cards();
        return ResponseEntity.ok(data);
    }

    //添加喜欢数据
    @GetMapping("/{id}/love")
    public ResponseEntity setLove(@PathVariable("id") Long id){
        recommend1Service.setLove(id);
        return ResponseEntity.ok(null);
    }
    //添加为不喜欢喜欢数据
    @GetMapping("/{id}/unlove")
    public ResponseEntity setUnLove(@PathVariable("id") Long id){
        recommend1Service.setUnLove(id);
        return ResponseEntity.ok(null);
    }

    //搜附近
    @GetMapping("/search")
    public ResponseEntity search(String gender,
                                 @RequestParam(defaultValue = "2000") String distance){
        List<NearUserVo> list =recommend1Service.search(gender, distance);
        return ResponseEntity.ok(list);
    }


}
